package c.e.a.b.e.c;

import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.RandomAccess;

/* compiled from: com.google.android.gms:play-services-measurement-base@@18.0.0 */
public final class m5 extends o3<String> implements l5, RandomAccess {
    public static final m5 c;
    public final List<Object> b;

    static {
        m5 m5Var = new m5(10);
        c = m5Var;
        m5Var.a = false;
    }

    public m5(int i) {
        this.b = new ArrayList(i);
    }

    public static String c(Object obj) {
        if (obj instanceof String) {
            return (String) obj;
        }
        if (obj instanceof t3) {
            t3 t3Var = (t3) obj;
            Objects.requireNonNull(t3Var);
            return t3Var.c() == 0 ? "" : t3Var.g(w4.a);
        }
        byte[] bArr = (byte[]) obj;
        Charset charset = w4.a;
        return new String(bArr, w4.a);
    }

    public final /* synthetic */ b5 a(int i) {
        if (i >= size()) {
            ArrayList arrayList = new ArrayList(i);
            arrayList.addAll(this.b);
            return new m5(arrayList);
        }
        throw new IllegalArgumentException();
    }

    public final /* synthetic */ void add(int i, Object obj) {
        String str = (String) obj;
        b();
        this.b.add(i, str);
        this.modCount++;
    }

    public final boolean addAll(Collection<? extends String> collection) {
        return addAll(size(), collection);
    }

    public final void clear() {
        b();
        this.b.clear();
        this.modCount++;
    }

    public final Object get(int i) {
        Object obj = this.b.get(i);
        if (obj instanceof String) {
            return (String) obj;
        }
        if (obj instanceof t3) {
            t3 t3Var = (t3) obj;
            Objects.requireNonNull(t3Var);
            Object g = t3Var.c() == 0 ? "" : t3Var.g(w4.a);
            if (t3Var.k()) {
                this.b.set(i, g);
            }
            return g;
        }
        byte[] bArr = (byte[]) obj;
        Charset charset = w4.a;
        String str = new String(bArr, w4.a);
        int i2 = 0;
        if (m7.a.a(0, bArr, 0, bArr.length) == 0) {
            i2 = 1;
        }
        if (i2 != 0) {
            this.b.set(i, str);
        }
        return str;
    }

    public final List<?> r() {
        return Collections.unmodifiableList(this.b);
    }

    public final /* synthetic */ Object remove(int i) {
        b();
        Object remove = this.b.remove(i);
        this.modCount++;
        return c(remove);
    }

    public final l5 s() {
        return this.a ? new g7(this) : this;
    }

    public final /* synthetic */ Object set(int i, Object obj) {
        String str = (String) obj;
        b();
        return c(this.b.set(i, str));
    }

    public final int size() {
        return this.b.size();
    }

    public final void t(t3 t3Var) {
        b();
        this.b.add(t3Var);
        this.modCount++;
    }

    public final Object u(int i) {
        return this.b.get(i);
    }

    public final boolean addAll(int i, Collection<? extends String> collection) {
        Collection collection2;
        b();
        if (collection2 instanceof l5) {
            collection2 = ((l5) collection2).r();
        }
        boolean addAll = this.b.addAll(i, collection2);
        this.modCount++;
        return addAll;
    }

    public m5(ArrayList<Object> arrayList) {
        this.b = arrayList;
    }
}
